<?php

namespace app\common\validate;

use think\Validate;

class Subject extends Validate
{

    /**
     * 验证规则
     */
    protected $rule = [
        'school_id'             => 'require',
        'number'                => 'require|unique:Subject,number^school_id',
        'name'                  => 'require',
    ];

    /**
     * 提示消息
     */
    protected $message = [
    ];

    /**
     * 字段描述
     */
    protected $field = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['school_id', 'number', 'name'],
        'edit'  => ['school_id', 'number' => 'require|unique:Subject,number^school_id^id', 'name'],
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'school_id' => '学校',
            'number' => '学科编号',
            'name' => '学科名称',
        ];
        parent::__construct($rules, $message, $field);
    }

}
